package com.zp.qualitypractice;

import android.content.Context;
import android.os.Environment;

import java.io.File;

/**
 * Created by izp on 2017/4/14.
 */

public class FileUtils {
    public final static String NETWORK_CACHE_DIR = "NetCache";
    /**
     * http 请求缓存空间
     *
     * @return
     */
    public static String getNetCacheDir(Context context,String cacheDirFolder) {
        return getCacheDir(context.getApplicationContext()) + File.separator + cacheDirFolder;
    }
    /**
     * 获取存放缓存的目录
     *
     * @return
     */
    public static String getCacheDir(Context context) {
        return getCacheFile(context).getAbsolutePath();
    }

    private static File getCacheFile(Context context) {
        File cache = null;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                || !Environment.isExternalStorageRemovable()) {
            cache = context.getExternalCacheDir();
        } else {
            cache = context.getCacheDir();
        }
        return cache;
    }

}
